/**
 * Created on 9 avr. 08 by Sebastian Audet
 */
package grid;

import java.util.TreeSet;

import tile.Tile;

/**
 * Defines a Node, which contain a TreeSet of Tiles, and a Location (x,y)
 * 
 * @author Sebastian Audet
 */
public interface Node extends Comparable<Node>{

    // Methods to deal with the state of the Node
    /**
     * Turns the Node Off
     */
    void turnOff();

    /**
     * Turns the Node On
     */
    void turnOn();

    /**
     * Toggles the state of the Node
     */
    void toggle();

    /**
     * @param b The boolean state to set the activity of this Node to
     */
    void setActive(boolean b);

    /**
     * @return The boolean status of this Node
     */
    boolean isActive();

    // Methods to deal with the content of a Node
    /**
     * @return A sorted set of the Tiles on the Node
     */
    TreeSet<Tile> returnTiles();

    /**
     * @return An Array of the Tiles on the Node
     */
    Tile[] returnArrayOfTiles();
    
    /**
     * 
     * @param level The level tile to return.
     * @return A Tile at the level, or else a null value if there exists to tile for
     * the requested level.
     */
    Tile returnLevel(int level);

    /**
     * @param set The TreeSet of tiles set for the Node
     */
    void setTiles(TreeSet<Tile> set);

    /**
     * @param set The array of Tiles to set for the Node
     */
    void setTiles(Tile[] set);

    /**
     * @param add The TreeSet of tiles add for the Node
     * @return The success of the operation
     */
    boolean addTiles(TreeSet<Tile> set);

    /**
     * @param add The array of to tiles to add for the Node
     * @return The success of the operation
     */
    boolean addTiles(Tile[] set);
    
    /**
     * Adds the tile to the Node
     * @param tile
     * @return The success of the operation
     */
    boolean addTile(Tile tile);

    /**
     * @return The number of tiles on this node
     */
    int tileCount();

    /**
     * Removes all tiles associated with this Node
     */
    void clearNode();

    /**
     * Clears the level of tile indicated
     * 
     * @param level The level of tile to clear
     */
    void clearNodeLevel(int level);

    /**
     * Finds and removes all instances of a Tile from the Node
     * 
     * @param tile The Tile to remove
     * @return The success of the removal
     */
    boolean removeTile(Tile tile);
    
    /**
     * @return The Location that this Node occupies
     */
    Location getLocation();
    
    /**
     * Returns true if the level is empty
     * @param level The level of Tile to check
     * @return The boolean state of the tile level being empty
     */
    boolean isEmpty(int level);
    
    /**
     * @param location The new location that this Node should occupy
     */
    void setLocation(Location location);
}
